package cn.edu.scau.cmi.zhangxiyang.Composite;

import java.util.HashSet;

public class ConComposite implements ConComponent{
	private String name;
	private HashSet<ConComponent> company = new HashSet<ConComponent>();
	
	public ConComposite(String name) {
		this.name = name;
	}
	
	@Override
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public void add(ConComponent c) {
		company.add(c);
	}
	
	@Override
	public void remove(ConComponent c) {
		company.remove(c);
	}
	
	@Override
	public String union() {
		String a = "";
		a += getName() + "\n";
		for(ConComponent c : company) {
			a += c.union() + "\n";
		}
		return a;
	}
}
